home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_6 / HARDIRQ.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  75 lines

  1. /* hardirq.h: 32-bit Sparc hard IRQ support.
  2.  *
  3.  * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  4.  * Copyright (C) 1998 Anton Blanchard (anton@progsoc.uts.edu.au)
  5.  */
  6.  
  7. #ifndef __SPARC_HARDIRQ_H
  8. #define __SPARC_HARDIRQ_H
  9.  
  10. #include <linux/tasks.h>
  11.  
  12. extern unsigned int local_irq_count[NR_CPUS];
  13.  
  14. /*
  15.  * Are we in an interrupt context? Either doing bottom half
  16.  * or hardware interrupt processing?
  17.  */
  18. #define in_interrupt() ({ int __cpu = smp_processor_id(); \
  19.     (local_irq_count[__cpu] + local_bh_count[__cpu] != 0); })
  20.  
  21. #ifndef __SMP__
  22.  
  23. #define hardirq_trylock(cpu)    (local_irq_count[cpu] == 0)
  24. #define hardirq_endlock(cpu)    do { } while (0)
  25.  
  26. #define hardirq_enter(cpu)    (local_irq_count[cpu]++)
  27. #define hardirq_exit(cpu)    (local_irq_count[cpu]--)
  28.  
  29. #define synchronize_irq()    barrier()
  30.  
  31. #else
  32.  
  33. #include <asm/atomic.h>
  34. #include <asm/spinlock.h>
  35. #include <asm/system.h>
  36. #include <asm/smp.h>
  37.  
  38. extern unsigned char global_irq_holder;
  39. extern spinlock_t global_irq_lock;
  40. extern atomic_t global_irq_count;
  41.  
  42. static inline void release_irqlock(int cpu)
  43. {
  44.     /* if we didn't own the irq lock, just ignore.. */
  45.     if (global_irq_holder == (unsigned char) cpu) {
  46.         global_irq_holder = NO_PROC_ID;
  47.         spin_unlock(&global_irq_lock);
  48.     }
  49. }
  50.  
  51. static inline void hardirq_enter(int cpu)
  52. {
  53.     ++local_irq_count[cpu];
  54.     atomic_inc(&global_irq_count);
  55. }
  56.  
  57. static inline void hardirq_exit(int cpu)
  58. {
  59.     atomic_dec(&global_irq_count);
  60.     --local_irq_count[cpu];
  61. }
  62.  
  63. static inline int hardirq_trylock(int cpu)
  64. {
  65.     return !atomic_read(&global_irq_count) && !*(((volatile unsigned char *)(&global_irq_lock)));
  66. }
  67.  
  68. #define hardirq_endlock(cpu)    do { } while (0)
  69.  
  70. extern void synchronize_irq(void);
  71.  
  72. #endif /* __SMP__ */
  73.  
  74. #endif /* __SPARC_HARDIRQ_H */
  75.